/* hash table declarations.
 * This file is a copy of hash.h in wget's source.
 */

#ifndef __HASH_H__
#define __HASH_H__

#ifdef __cplusplus
extern "C" {
#endif

struct hash_table;

struct hash_table *hash_table_new( int items, unsigned long (*hash_function)( const void * ),
	int (*test_function)( const void *, const void * ));
void hash_table_destroy( struct hash_table *ht );

void *hash_table_get( const struct hash_table *ht, const void *key );
int hash_table_get_pair( const struct hash_table *ht, const void *lookup_key,
		void *orig_key, void *value );

int hash_table_contains( const struct hash_table *ht, const void *key );

void hash_table_put( struct hash_table *ht, const void *key, void *value );
int hash_table_remove( struct hash_table *ht, const void *key );
void hash_table_clear( struct hash_table *ht );

void hash_table_for_each( struct hash_table *ht,
	int (*fn)( void *, void *, void * ), void *arg );

typedef struct {
	void *key, *value;      /* public members */
	void *pos, *end;        /*private members */
} hash_table_iterator;
void hash_table_iterate( struct hash_table *, hash_table_iterator *iter );
int hash_table_iter_next( hash_table_iterator *iter );

int hash_table_count( const struct hash_table * );

struct hash_table *make_string_hash_table( int items );
struct hash_table *make_nocase_string_hash_table( int items );

unsigned long hash_pointer( const void *ptr );

#ifdef __cplusplus
}
#endif

#endif /* __HASH_H__ */
